# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def deleteDuplicates(self, head: ListNode) -> ListNode:
        dummy=ListNode(next=head)
        now=dummy
        go=head
        while go:
            prev=go
            c=0
            while go and go.val==prev.val:
                c+=1
                go=go.next
            if c>1:
                now.next=go
            else:
                now=prev
        return dummy.next

# 执行用时：
# 44 ms
# , 在所有 Python3 提交中击败了
# 84.86%
# 的用户
# 内存消耗：
# 15 MB
# , 在所有 Python3 提交中击败了
# 13.88%
# 的用户